package com.dailytopic;

import java.util.Arrays;

/**
 * @Author: huangzhigao
 * @Date: 2022/2/26 15:44
 */
public class leecode2016 {
    public static int maximumDifference(int[] nums) {
        int min = nums[0];
        int max = -1;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] > min) {
                max = Math.max(max, nums[i] - min);
            }
            min = Math.min(min, nums[i]);
        }
        return max;
    }

    public static void main(String[] args) {
        int[] s = {999, 997, 980, 976, 948, 940, 938, 928, 924, 917, 907, 907};
        System.out.println(maximumDifference(s));

    }

}
